package sevensoft.行为型模式.责任链模式;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public abstract class Handler {


    private Handler nextHandler;

    private int handlerDays;

    private String name;

    protected abstract void handlerLeave(LeaveRequest leaveRequest);

    public void submit(LeaveRequest leaveRequest) {
        handlerLeave(leaveRequest);
        if ( nextHandler != null && leaveRequest.getDays() > handlerDays ) {
            nextHandler.submit(leaveRequest);
        }

    }


}
